package de.justphil.tcg.tcgserver.game.mechanics.example;

import java.util.Random;

import de.justphil.tcg.tcgserver.game.mechanics.config.Config;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.Bigfoot;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.BullFrog;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.Cerberus;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.Elephant;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.ElfMage;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.Goblin;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.HedgeHog;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.MagicRock;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.Roadrunner;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.Snake;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.WildBore;
import de.justphil.tcg.tcgserver.game.mechanics.example.monsters.Wolf;
import de.justphil.tcg.tcgserver.game.mechanics.monster.Monster;
import de.justphil.tcg.tcgserver.game.mechanics.monster.MonsterList;

import org.slf4j.Logger;
import static de.justphil.tcg.tcgserver.commons.logging.TCGLogging.*;

public class DeckCreator {

	private static final Logger log = gameLogger(DeckCreator.class);

	private MonsterList cardSupply;

	public DeckCreator() {

		cardSupply = new MonsterList();

		cardSupply.add(new Elephant(10101));
		cardSupply.add(new Elephant(10102));
		cardSupply.add(new Elephant(10103));
		cardSupply.add(new Elephant(10104));
		cardSupply.add(new Elephant(10105));
		cardSupply.add(new Elephant(10106));
		cardSupply.add(new Elephant(10107));
		cardSupply.add(new Elephant(10108));
		cardSupply.add(new Elephant(10109));

		cardSupply.add(new BullFrog(10201));
		cardSupply.add(new BullFrog(10202));
		cardSupply.add(new BullFrog(10203));
		cardSupply.add(new BullFrog(10204));
		cardSupply.add(new BullFrog(10205));
		cardSupply.add(new BullFrog(10206));
		cardSupply.add(new BullFrog(10207));
		cardSupply.add(new BullFrog(10208));
		cardSupply.add(new BullFrog(10209));

		cardSupply.add(new Cerberus(10301));
		cardSupply.add(new Cerberus(10302));
		cardSupply.add(new Cerberus(10303));
		cardSupply.add(new Cerberus(10304));
		cardSupply.add(new Cerberus(10305));
		cardSupply.add(new Cerberus(10306));
		cardSupply.add(new Cerberus(10307));
		cardSupply.add(new Cerberus(10308));
		cardSupply.add(new Cerberus(10309));

		cardSupply.add(new Snake(10401));
		cardSupply.add(new Snake(10402));
		cardSupply.add(new Snake(10403));
		cardSupply.add(new Snake(10404));
		cardSupply.add(new Snake(10405));
		cardSupply.add(new Snake(10406));
		cardSupply.add(new Snake(10407));
		cardSupply.add(new Snake(10408));
		cardSupply.add(new Snake(10409));

		cardSupply.add(new Roadrunner(10501));
		cardSupply.add(new Roadrunner(10502));
		cardSupply.add(new Roadrunner(10503));
		cardSupply.add(new Roadrunner(10504));
		cardSupply.add(new Roadrunner(10505));
		cardSupply.add(new Roadrunner(10506));
		cardSupply.add(new Roadrunner(10507));
		cardSupply.add(new Roadrunner(10508));
		cardSupply.add(new Roadrunner(10509));

		cardSupply.add(new Wolf(10601));
		cardSupply.add(new Wolf(10602));
		cardSupply.add(new Wolf(10603));
		cardSupply.add(new Wolf(10604));
		cardSupply.add(new Wolf(10605));
		cardSupply.add(new Wolf(10606));
		cardSupply.add(new Wolf(10607));
		cardSupply.add(new Wolf(10608));
		cardSupply.add(new Wolf(10609));

		cardSupply.add(new ElfMage(10701));
		cardSupply.add(new ElfMage(10702));
		cardSupply.add(new ElfMage(10703));
		cardSupply.add(new ElfMage(10704));
		cardSupply.add(new ElfMage(10705));
		cardSupply.add(new ElfMage(10706));
		cardSupply.add(new ElfMage(10707));
		cardSupply.add(new ElfMage(10708));
		cardSupply.add(new ElfMage(10709));

		cardSupply.add(new Goblin(10801));
		cardSupply.add(new Goblin(10802));
		cardSupply.add(new Goblin(10803));
		cardSupply.add(new Goblin(10804));
		cardSupply.add(new Goblin(10805));
		cardSupply.add(new Goblin(10806));
		cardSupply.add(new Goblin(10807));
		cardSupply.add(new Goblin(10808));
		cardSupply.add(new Goblin(10809));

		cardSupply.add(new WildBore(10901));
		cardSupply.add(new WildBore(10902));
		cardSupply.add(new WildBore(10903));
		cardSupply.add(new WildBore(10904));
		cardSupply.add(new WildBore(10905));
		cardSupply.add(new WildBore(10906));
		cardSupply.add(new WildBore(10907));
		cardSupply.add(new WildBore(10908));
		cardSupply.add(new WildBore(10909));

		cardSupply.add(new HedgeHog(11001));
		cardSupply.add(new HedgeHog(11002));
		cardSupply.add(new HedgeHog(11003));
		cardSupply.add(new HedgeHog(11004));
		cardSupply.add(new HedgeHog(11005));
		cardSupply.add(new HedgeHog(11006));
		cardSupply.add(new HedgeHog(11007));
		cardSupply.add(new HedgeHog(11008));
		cardSupply.add(new HedgeHog(11009));

		cardSupply.add(new Bigfoot(11101));
		cardSupply.add(new Bigfoot(11102));
		cardSupply.add(new Bigfoot(11103));
		cardSupply.add(new Bigfoot(11104));
		cardSupply.add(new Bigfoot(11105));
		cardSupply.add(new Bigfoot(11106));
		cardSupply.add(new Bigfoot(11107));
		cardSupply.add(new Bigfoot(11108));
		cardSupply.add(new Bigfoot(11109));

		cardSupply.add(new MagicRock(11201));
		cardSupply.add(new MagicRock(11202));
		cardSupply.add(new MagicRock(11203));
		cardSupply.add(new MagicRock(11204));
		cardSupply.add(new MagicRock(11205));
		cardSupply.add(new MagicRock(11206));
		cardSupply.add(new MagicRock(11207));
		cardSupply.add(new MagicRock(11208));
		cardSupply.add(new MagicRock(11209));
	}

	public MonsterList getRandomDeck(long seed) {

		log.info("Generating random Deck with seed {}.", new Object[] { seed });

		final Random random = new Random(seed);

		final MonsterList deck = new MonsterList();
		
		for(int i = 0; i < Config.DECK_SIZE; i++){
			
			Monster monster = cardSupply.remove(random.nextInt(cardSupply.size()));
			deck.add(monster);
			log.info(" + ({}).", new Object[] {monster});
		}

		return deck;
	}
}
